package com.ruoyi.web.controller.material;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.material.domain.PurchaseOrderInspect;
import com.ruoyi.material.service.IPurchaseOrderInspectService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购单查验记录Controller
 *
 * @author wng
 * @date 2024-08-04
 */
@RestController
@RequestMapping("/material/inspect")
public class PurchaseOrderInspectController extends BaseController {
    @Resource
    private IPurchaseOrderInspectService purchaseOrderInspectService;

    /**
     * 查询采购单查验记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:list')")
    @GetMapping("/list")
    public TableDataInfo list(PurchaseOrderInspect purchaseOrderInspect) {
        startPage();
        List<PurchaseOrderInspect> list = purchaseOrderInspectService.selectPurchaseOrderInspectList(purchaseOrderInspect);
        return getDataTable(list);
    }

    /**
     * 导出采购单查验记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:export')")
    @Log(title = "采购单查验记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchaseOrderInspect purchaseOrderInspect) {
        List<PurchaseOrderInspect> list = purchaseOrderInspectService.selectPurchaseOrderInspectList(purchaseOrderInspect);
        ExcelUtil<PurchaseOrderInspect> util = new ExcelUtil<PurchaseOrderInspect>(PurchaseOrderInspect.class);
        util.exportExcel(response, list, "采购单查验记录数据");
    }

    /**
     * 获取采购单查验记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(purchaseOrderInspectService.selectPurchaseOrderInspectById(id));
    }

    /**
     * 新增采购单查验记录
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:add')")
    @Log(title = "采购单查验记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurchaseOrderInspect purchaseOrderInspect) {
        return toAjax(purchaseOrderInspectService.insertPurchaseOrderInspect(purchaseOrderInspect));
    }

    /**
     * 修改采购单查验记录
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:edit')")
    @Log(title = "采购单查验记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurchaseOrderInspect purchaseOrderInspect) {
        return toAjax(purchaseOrderInspectService.updatePurchaseOrderInspect(purchaseOrderInspect));
    }

    /**
     * 删除采购单查验记录
     */
    @PreAuthorize("@ss.hasPermi('system:inspect:remove')")
    @Log(title = "采购单查验记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(purchaseOrderInspectService.deletePurchaseOrderInspectByIds(ids));
    }
}
